package com.example.demo20230927;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {

    @Autowired
    private BookMapper bookMapper;

    @PostMapping("/add")
    public String addBook(@RequestBody Book book) {
        bookMapper.insertBook(book);
        return "图书添加成功";
    }

    @GetMapping("/search")
    public List<Book> searchBookByName(@RequestParam("title") String title) {
        return bookMapper.findByTitleLike(title);
    }
}